package com.neusoft.elm.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.neusoft.elm.po.Business;
import com.neusoft.elm.service.BusinessService;
import com.neusoft.elm.service.impl.BusinessServiceImpl;

public class BusinessController {

    public Object list(HttpServletRequest request) throws Exception {
        System.out.println("BusinessController.list() 被调用");
        BusinessService service = new BusinessServiceImpl();
        List<Business> list = service.listAllBusinesses();
        System.out.println("获取到的商家列表大小: " + (list != null ? list.size() : 0));
        return list;
    }

    public Object listBusinessByOrderTypeId(HttpServletRequest request) throws Exception {
        System.out.println("BusinessController.listBusinessByOrderTypeId() 被调用");
        Integer orderTypeId = Integer.valueOf(request.getParameter("orderTypeId"));
        System.out.println("orderTypeId: " + orderTypeId);
        BusinessService service = new BusinessServiceImpl();
        List<Business> list = service.listBusinessByOrderTypeId(orderTypeId);
        System.out.println("获取到的商家列表大小: " + (list != null ? list.size() : 0));
        return list;
    }

    public Object getBusinessById(HttpServletRequest request) throws Exception {
        System.out.println("BusinessController.getBusinessById() 被调用");
        Integer businessId = Integer.valueOf(request.getParameter("businessId"));
        System.out.println("businessId: " + businessId);
        BusinessService service = new BusinessServiceImpl();
        Business business = service.getBusinessById(businessId);
        System.out.println("获取到的商家信息: " + business);
        return business;
    }
}
